import redis
import time
if __name__ == '__main__':
    # 创建redis连接
    con = redis.Redis(host="master", port=6379, decode_responses=True, encoding="UTF-8")

    print("==============银行叫号系统======================")

    num = input("请输入1叫号")

    if num == "1":
        # 构建计数器的key
        localtime = time.localtime()
        year = localtime.tm_year
        mon = localtime.tm_mon
        day = localtime.tm_mday
        # 获取当前日期
        date = f"{year}{mon}{day}"
        # 构建排号的key
        paidui_key  = f"paidui:{date}"
        # 取出一个号
        haoma = con.rpop(paidui_key)
        print(f"请{haoma}到1号窗口办理业务")
    else:
        print("输入有误")
